package org.adream.account.controller;

import org.adream.account.aop.annotation.MonitorRequest;
import org.adream.account.entity.ResourceEntity;
import org.adream.account.service.ResourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 资源管理模块相关页面
 * @author sl
 *
 */
@Controller
public class ResourceController {
	
	private final static Logger logger = LoggerFactory.getLogger(ResourceController.class);
	
	@Autowired
	private ResourceService resourceService;
	
	//资源列表页面
	@RequestMapping(value = "/resourcePage")
	public ModelAndView resource() {
		ModelAndView mv = new ModelAndView("/res/resource");
		return mv;
	}
	
	//资源添加页面
	@RequestMapping(value = "/resourceAddPage")
	@MonitorRequest
	public ModelAndView resourceAdd() {
		ModelAndView mv = new ModelAndView("/res/resource_add");
		return mv;
	}
	
	//资源编辑页面
	@RequestMapping(value = "/resourceEditPage")
	public ModelAndView resourceEdit(String resId) {
		ModelAndView mv = new ModelAndView("/res/resource_edit");
		ResourceEntity resource = resourceService.queryResourceByResId(resId);
		mv.getModel().put("resource", resource);
		return mv;
	}
}